package com.xgst.bmg;

import com.xgst.bmg.server.RTMPServer;
import com.xgst.bmg.server.manager.StreamManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Slf4j
@EnableAsync
@EnableScheduling
@SpringBootApplication
public class CaptureScreenApplication implements WebMvcConfigurer {

	public static void main(String[] args) {
		try {
			StreamManager streamManager = new StreamManager();
			RTMPServer rtmpServer = new RTMPServer(1935, streamManager,8);
			rtmpServer.run();
		} catch (Exception e) {
			e.printStackTrace();
		}

		System.setProperty("java.awt.headless", "false");
		SpringApplication.run(CaptureScreenApplication.class, args);
	}

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("/myPcServer/**").addResourceLocations("file:C:/file/");
	}
}
